package com.base.taskreports.demoExel;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.base.taskreports.common.utlis.ExcelUtils;
import com.base.taskreports.common.utlis.FileUtils;
import com.base.taskreports.demoExel.entity.Indicator;

public class Demo01 {

    public static void main(String[] args) throws IOException {

        long startTime = System.currentTimeMillis();

        String toDay = new SimpleDateFormat("yyyyMMdd").format(new Date());

        String outPath = "E:\\demo\\ncs-base-master\\ncs-base-master\\ncs-base-task\\src\\main\\java\\com\\ncs\\base\\common\\rule\\exel\\报表展示模板.xlsx";
        String newPath = "E:\\demo\\ncs-base-master\\ncs-base-master\\ncs-base-task\\src\\main\\java\\com\\ncs\\base\\common\\rule\\exel\\报表展示模板_" + toDay + ".xlsx";

        int stratRow = 3;

        FileUtils.deleteFile(newPath);
        FileUtils.copyFileUsingJava7Files(new File(outPath), new File(newPath));

        ExcelUtils.addHeaderDate(newPath); // 为所有 Sheet 表头加入日期

        List<List<Object>> list = null;
        List<Object> objectList = null;

        for (Indicator indicator : Indicator.values()) {
            list = new ArrayList();

            for (int i = 1; i <= 10; i++) {
                objectList = new ArrayList<Object>();
                objectList.add(indicator.getName() + "-" + i);
                objectList.add("50");
                objectList.add("340");
                objectList.add("755");
                objectList.add("1");

                list.add(objectList);
            }
            System.out.println(ExcelUtils.addExcelSheetContent(newPath, indicator.getIndex(), stratRow, list) ? "成功" : "失败");
            System.out.print(System.currentTimeMillis() - startTime);
            //System.out.println(ExcelUtils.addExcelSheetContent(newPath, indicator.getIndex(), stratRow, list) ? "成功" : "失败");
        }

        System.out.println("-------------------------" + (System.currentTimeMillis() - startTime));

    }




}
